<!DOCTYPE html>
<html>
  <head>
    <title>{% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %}</title>
    {% block head_meta %}
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
    {% endblock %}
    {% block head_css %}
        <link href="{{ url_for('admin.static', filename='bootstrap/css/bootstrap.css') }}" rel="stylesheet">
        <link href="{{ url_for('admin.static', filename='bootstrap/css/bootstrap-responsive.css') }}" rel="stylesheet">
        <link href="{{ url_for('admin.static', filename='css/admin.css') }}" rel="stylesheet">
    {% endblock %}
    {% block head %}
    {% endblock %}
  </head>
  <body>
    {% block page_body %}
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          {% block brand %}
          <span class="brand">{{ admin_view.admin.name }}</span>
          {% endblock %}
          <ul class="nav">
            {% for item in admin_view.admin.menu() %}
              {% if item.is_category() %}
                {% set children = item.get_children() %}
                {% if children %}
                  {% if item.is_active(admin_view) %}<li class="active dropdown">{% else %}<li class="dropdown">{% endif %}
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{ item.name }}<b class="caret"></b></a>
                    <ul class="dropdown-menu">
                      {% for child in children %}
                      {% if child.is_active(admin_view) %}<li class="active">{% else %}<li>{% endif %}
                        <a href="{{ child.get_url() }}">{{ child.name }}</a>
                      </li>
                      {% endfor %}
                    </ul>
                  </li>
                {% endif %}
              {% else %}
                {% if item.is_accessible() %}
                  {% if item.is_active(admin_view) %}<li class="active">{% else %}<li>{% endif %}
                    <a href="{{ item.get_url() }}">{{ item.name }}</a>
                  </li>
                {% endif %}
              {% endif %}
            {% endfor %}
          </ul>
        </div>
      </div>
    </div>

    {% with messages = get_flashed_messages(with_categories=True) %}
      {% if messages %}
        {% for category, m in messages %}
          {% if category == 'error' %}
          <div class="alert alert-error">
          {% else %}
          <div class="alert">
          {% endif %}
            <a href="#" class="close" data-dismiss="alert">x</a>
            {{ m }}
          </div>
        {% endfor %}
      {% endif %}
    {% endwith %}

    <div class="container">
      {% block body %}{% endblock %}
    </div>
    {% endblock %}

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <script src="{{ url_for('admin.static', filename='bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
    <script src="{{ url_for('admin.static', filename='select2/select2.min.js') }}" type="text/javascript"></script>

    {% block tail %}
    {% endblock %}
  </body>
</html>
